package com.hzdesk.media.koreabatchmatvector.fragment.fragment_view;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.hzdesk.media.koreabatchmatvector.R;
import com.hzdesk.media.koreabatchmatvector.config.RxBusUtil;
import com.hzdesk.media.koreabatchmatvector.fragment.fragment_contract.CloudListContract;
import com.hzdesk.media.koreabatchmatvector.fragment.fragment_persenter.CloudListPersenter;
import com.hzdesk.media.koreabatchmatvector.logic.view.DialogActivity;
import com.hzdesk.media.koreabatchmatvector.utils.MyToastUtils;
import com.hzdesk.media.koreabatchmatvector.utils.RxBus;

import com.orhanobut.logger.Logger;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import me.zhouzhuo.zzhorizontalprogressbar.ZzHorizontalProgressBar;

/**
 * Created by Administrator on 2018/6/22.
 * 杭州席媒科技有限公司  Developers  刘传华  15
 * 佛祖镇楼 bug辟易
 */

public class CloudListFragment extends BaseFragment implements CloudListContract.ICloudListView{
    @BindView(R.id.fragment_cloud_list_iv_back)
    ImageView fragmentCloudListIvBack;
    @BindView(R.id.fragment_cloud_list_iv_intent_to_local)
    ImageView fragmentCloudListIvIntentToLocal;
    @BindView(R.id.fragment_cloud_list_iv_delect_all)
    ImageView fragmentCloudListIvDelectAll;
    @BindView(R.id.fragment_cloud_list_iv_sort)
    ImageView fragmentCloudListIvSort;
    @BindView(R.id.fragment_cloud_list_progress)
    ZzHorizontalProgressBar fragmentCloudListProgress;
    @BindView(R.id.fragment_cloud_list_tv_storage)
    TextView fragmentCloudListTvStorage;
    @BindView(R.id.fragment_cloud_listview)
    RecyclerView fragmentCloudListview;
    Unbinder unbinder;


    private CloudListPersenter mCloudListPersenter = new CloudListPersenter(this);

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_cloud_list, container, false);
        unbinder = ButterKnife.bind(this, view);
        mCloudListPersenter.initRecyclerview(mcontext, fragmentCloudListview);
        mCloudListPersenter.initSpace(fragmentCloudListProgress,mcontext,fragmentCloudListTvStorage);
        return view;
    }

    @OnClick({R.id.fragment_cloud_list_iv_back, R.id.fragment_cloud_list_iv_intent_to_local,
            R.id.fragment_cloud_list_iv_delect_all, R.id.fragment_cloud_list_iv_sort,
            R.id.fragment_cloud_list_progress, R.id.fragment_cloud_list_tv_storage})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.fragment_cloud_list_iv_back:
                mCloudListPersenter.onClickLocal(RxBusUtil.SET_FRAGMENT_BACK);
                break;
            case R.id.fragment_cloud_list_iv_intent_to_local:
                mCloudListPersenter.onClickLocal(RxBusUtil.CHANGE_VIDEO_LIST_FRAGMENT);
                break;
            case R.id.fragment_cloud_list_iv_delect_all:
                mCloudListPersenter.delectAllFile();
                break;
            case R.id.fragment_cloud_list_iv_sort:
                mCloudListPersenter.sortingList();
                break;
            case R.id.fragment_cloud_list_progress:
                break;
            case R.id.fragment_cloud_list_tv_storage:
                break;
        }
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();

    }

    @Override
    public void sendMessgeLocal(int pager) {
       // RxBus.getInstance().send(pager); //显示视频列表页面 2
//        if(pager == RxBusUtil.CHANGE_VIDEO_LIST_FRAGMENT){
//            Intent intent = new Intent(mcontext, DialogActivity.class);
//            intent.putExtra("Dialog_viewpage_index",pager);
//            mcontext.startActivity(intent);
//        }else{
//            RxBus.getInstance().send(pager); //显示视频列表页面
//        }
        RxBus.getInstance().send(pager);
        Logger.d("hello %s %d", "world", pager);
    }

    @Override
    public void showToast(String message) {
        MyToastUtils.ShortToaseShow(mcontext,message);
    }
}
